package com.enjoy.book.dao;

import com.enjoy.book.bean.Book;
import com.enjoy.book.util.DBHelper;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.commons.dbutils.handlers.ScalarHandler;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

/**
 * @author陈俊威
 */
public interface BookDao {
    /**
     * 添加图书
     * @param name
     * @param price
     * @param desc
     * @param publish
     * @param author
     * @param stock
     * @param address
     * @return
     * @throws SQLException
     */
    public int add(String name,double price,String desc,
                   String publish,String author,long stock,String address) throws SQLException ;

    /**
     * 修改图书
     * @param id
     * @param name
     * @param price
     * @param desc
     * @param publish
     * @param author
     * @param stock
     * @param address
     * @return
     * @throws SQLException
     */
    public int modify(long id,String name,double price,String desc,
                      String publish,String author,long stock,String address) throws SQLException ;


    /**
     * 删除图书
     * @param id
     * @return
     * @throws SQLException
     */
    public int remove(long id) throws SQLException ;

    /**
     * 计算图书页大小
     * @param pageIndex
     * @param pageSize
     * @return
     * @throws SQLException
     */
    public List<Book> getByPage(int pageIndex, int pageSize) throws SQLException ;


    /**
     * 获取图书名称
     * @param name
     * @return
     * @throws SQLException
     */
    public Book getByName(String  name) throws SQLException ;

    /**
     * 获取图书的id编号
     * @param id
     * @return
     * @throws SQLException
     */
    public Book getById(long id) throws SQLException ;


    /**
     * 获取库存数量
     * @return
     * @throws SQLException
     */
    public int  getCount() throws SQLException ;

    /**
     * 修改方法的重载
     * @param id
     * @param amount
     * @return
     * @throws SQLException
     */
    public int modify(long id,int amount) throws SQLException ;
}
